var myVue = new Vue({
	el: "body",
	data: {
		shop: [],
		swiper1: [{
			name: "美食",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "简餐",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "盖浇饭",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "汉堡",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "日韩料理",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "意面披萨",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "面包",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "饮料",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}],
		swiper2: [{
			name: "麻辣烫",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "米粉面馆",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "麻辣香锅",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "煲仔饭",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "黄焖鸡",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "西北菜",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, {
			name: "鲁菜",
			img: "//fuss10.elemecdn.com/b/7e/d1890cf73ae6f2adb97caa39de7fcjpeg.jpeg?imageMogr/format/webp/"
		}, ],
		loading: true,
	},
	methods: {
		targetShopmain: function(index) {
			var newUrl = "?shopid=" + this.shop[index].id
			window.location.href = "../shopmain/shopmain.html" + newUrl;
		},
		targetShoplist1: function(index) {
			var name = set(this.swiper1[index].name)
			window.location.href = "../shoplist/shoplist.html?mainWord=" + name;
		},
		targetShoplist2: function(index) {
			window.location.href = "../shoplist/shoplist.html?mainWord=" + this.swiper2[index].name;
		}
	},
	beforecreate: function() {

	},
	created: function() {
		var this_shop = this.shop;
		var this_id;
		var this_img;
		var this_name;
		var this_ratewarp;
		var this_moneylimit;
		var this_sendprice;
		init();
		var query = new AV.Query('ELM_shop');
		//				query.include('owner');
		//				query.include('image');
		query.find().then(function(shoplist) {
			// 查询到商品后，在前端展示到相应的位置中

			for(var i = 0; i < shoplist.length; i++) {
				this_id = shoplist[i].id;
				this_img = shoplist[i].attributes.shopimg;
				this_name = shoplist[i].attributes.shopname;
				this_rateWarp = shoplist[i].attributes.salenum;
				this_moneylimit = shoplist[i].attributes.startprice;
				this_sendprice = shoplist[i].attributes.sendprice;
				this_grade = shoplist[i].attributes.grade;
				var grade = parseInt(this_grade);
				var thisGrade = [];
				for(var j = 0; j < grade; j++) {
					thisGrade.push(j);
				}
				var shop = {
					id: this_id,
					img: this_img,
					name: this_name,
					ratewarp: this_rateWarp,
					moneylimit: this_moneylimit,
					sendprice: this_sendprice,
					grade: thisGrade,
				}
				this_shop.push(shop);
			}

		}).catch(function(error) {
			console.log(error);
		});
	},
	updated: function() {
		this.loading = true;
	}
})